//Iditarod Trail
//Amelia Bauer, Elise Eiden, Christine Gerardi, Taryn Green
//CSE 20212 2012
/*Base class for Dogs
Contains data members present in all dogs*/
#include <iostream>
#include "Dog.h"
#include <cstdlib>
using namespace std;

//Default constructor
Dog:: Dog()				//Dog always starts with full strength, alive, and not tired 
{
	name = "Matt Damon";
	alive = 1;
	fatigue = 0;
	strength = 5;			//10 point scales 
	health = 10;
}
//Nondefault constructor 
Dog:: Dog(string n, int s) 		//Dog always starts with full strength, alive, and not tired 
{
	name = n;
	strength = s;
	alive = 1;
	fatigue = 0;
	health = 10;
}
Dog:: Dog(int a)
{
	name = "";
	alive = 0;			//Dead dog to begin with 
	fatigue = 0;
	strength = 5;			//10 point scales 
	health = 10;
}
//Get and set functions//
void Dog::setFatigue(int fat)
{
	fatigue = fat;
}
void Dog:: rest()
{
	if(fatigue > .1)
		fatigue -= .2;
	else if(fatigue ==.1)
		fatigue = 0;
	else if(fatigue <.1)
		return;
	if(health >=10)
		return;
	health ++;
}
void Dog:: timeAdvance()
{
	fatigue += .1;
	if(fatigue >= .5)
	{
		if(health > 0)
		{
			int randNum = rand()%20;
			if(randNum <= 3)
				health--;
		}
	}
}

int Dog:: getFatigue()
{
	return fatigue;
}

int Dog:: getStrength()
{
	return strength;
}
int Dog:: checkAlive()
{
	return alive;
}
string Dog:: getName() 
{
	return name;
}
void Dog:: setName(string name_in)
{
	name = name_in;
}
//Sets dog to dead
void Dog:: kill()				//Call if fatigue 0 or health 0
{
	alive = 0;
	fatigue = 0.0;
	strength = 0;
	health = -1;
	
}
void Dog:: makeAlive()
{
	alive = 1;
	fatigue = 0.0;
	strength = 5;			//10 point scales 
	health = 10;
}
//Determines power (which is strength minus fatigue)
float Dog:: calcSpeed()
{
	if(health <=3)
		return 0;
	else if(fatigue > (float) strength)
		return 0;
	else if(((float) strength - fatigue) < 2)
		return 2;
	return ((float) strength - fatigue);
}
int Dog:: getHealth()
{
	return health;
}
void Dog:: useMedicineDog()
{
	health = 10;
}
void Dog::starve()
{	health--;	
	if(health<0)
		health=0;

}
